package mx.controls
{
	import flash.events.MouseEvent;

	import mx.collections.IList;
	import mx.events.ItemClickEvent;


/**
 * Provides a stateful linkbar when the dataprovider is not VIEWSTACK but Array/IList.
 */
public class LinkBarExtended extends LinkBar
{
	// Constructor
	public function LinkBarExtended() {
		super();
	}

	/**
	 * Sets the selected index, updates the UI.
	 */
	public function setSelectedIndexAndUpdateUI(selectedIndex_:int):void {
		selectedIndex = selectedIndex_;

		// hiliteSelectedNavItem(selectedIndex);
		for(var i:int = 0; i < numChildren; i++) {
			var button:Button = getChildAt(i) as Button;
			button.enabled = i != selectedIndex_;
		}

		// do not dispatch any ItemClick event - which will cause MAGeneralNavigation troubles.
	}

	override protected function clickHandler(event:MouseEvent):void {
		var index:int = getChildIndex(event.currentTarget as Button);
		if(index == selectedIndex) {
			hiliteSelectedNavItem(-1);
		}else{
			hiliteSelectedNavItem(index);
		}

		super.clickHandler(event);
	}

} // End class
} // End package